import request from '@/utils/request'
import { AxiosPromise } from 'axios'

enum Api {
  list = '/notifyConfig/list',
  add = '/notifyConfig/add',
  edit = '/notifyConfig/edit',
  changeStatus = '/notifyConfig/changeStatus',
  changeProperties = '/notifyConfig/changeProperties',
}

export const notifyList = (data): AxiosPromise<any> => {
  return request({
    url: Api.list,
    method: 'post',
    data,
  })
}
// 编辑、保存
export const notifySave = (data: any) => {
  return request({
    url: data.id ? Api.edit : Api.add,
    method: 'post',
    data,
  })
}

export const changeProperties = (data: any) => {
  return request({
    url: Api.changeProperties,
    method: 'post',
    data,
  })
}

// 状态修改
export function changeStatus(id: string | number, status: number) {
  const data = {
    id,
    status,
  }
  return request({
    url: Api.changeStatus,
    method: 'post',
    data,
  })
}
